package projectbs;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class TestClient {
	public static void main(String[] args) throws IOException,
			InterruptedException, ExecutionException, TimeoutException {
		AsynchronousSocketChannel channel = AsynchronousSocketChannel.open();
		Future<Void> fur = channel.connect(new InetSocketAddress("saddybox-15806.use1.actionbox.io",
				8000));
		fur.get(1, TimeUnit.SECONDS);
		String msg = "test messgae";
		ByteBuffer buffer = ByteBuffer.allocate(30);
		buffer.putInt(msg.length() + 2 + 4);
		buffer.putInt(0);
		buffer.put(msg.getBytes());
		buffer.flip();
		channel.write(buffer);
		Thread.sleep(3);
	}
}
